<?php
class Js{
    static function alert($text){
        $text = 'alert("'.$text.'");';
        return Js::script($text);
    }
    //显示script
    static function script($text){
        $s = '<script type="text/javascript">';
        $s.=$text;
        $s.='</script>';
        return $s;
    }
    //返回指定页面
    static function to_url($url){
        $s='window.location.href="'.$url.'"';
        return Js::script($s);
    }
    //框架页跳转
    static function top_to_url($url){
        $s = 'window.top.location.href="'.$url.'"';
        return Js::script($s);
    }
    //返回上一页
    static function go_back(){
        $s='window.history.back();';
        return Js::script($s);
    }
    //默认焦点
    static function focus(){
        $s = 'document.getElementById("focus").focus();';
        $s = Js::onload($s);
        $s = Js::script($s);
    }
    //Js默认HTML执行函数
    static function onload($str){
        $s = 'window.onload = function(){'.$str.'}';
        return $s;
    }
    //上一页刷新
    static function refre(){
        $s = 'window.parent.location.reload();';
        $s = Js::script($s);
    }
}
